
class Mythread1 extends Thread {

    @Override
    public void run() {
        System.out.println("继承 Thread, 重写 run");
    }
}


class Mythread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("实现 Runnable, 重写 run");
    }
}





public class Mydemo1 {
    public static void main(String[] args) {
        Thread thread=new Mythread1();
//        Mytread mytread=new Mytread();
        thread.start();


//        Mythread2 mythread2=new Mythread2();
        Thread thread1=new Thread(new Mythread2());
        thread1.start();


        Thread thread2=new Thread(){
            @Override
            public void run() {
                System.out.println("继承 Thread, 重写 run, 使用匿名内部类");
            }
        };
        thread2.start();


        Thread thread3=new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("实现 Runnable, 重写 run, 使用匿名内部类");
            }
        });
        thread3.start();


        Thread thread4=new Thread(()->{
            System.out.println("使用 lambda 表达式");
        });
        thread4.start();

    }
}
